package com.hxht.cmp.websocket;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.socket.config.annotation.EnableWebSocket;
import org.springframework.web.socket.config.annotation.WebSocketConfigurer;
import org.springframework.web.socket.config.annotation.WebSocketHandlerRegistry;

/**
 * @author alice on 2017/7/31 0031.
 * @version 1.0
 * @since 1.0
 */
@Configuration
@EnableWebSocket
public class WebSocketConfig implements WebSocketConfigurer {
    @Override
    public void registerWebSocketHandlers(WebSocketHandlerRegistry registry) {
        //注册websocket实现类，指定参数访问地址;allowed-origins="*" 允许跨域
//        registry.addHandler(null, "/ws").addInterceptors().setAllowedOrigins("*");
        //允许客户端使用SockJS
//        registry.addHandler(null, "/sockjs/ws").addInterceptors().withSockJS();
    }
}
